"""
Author: yida
Time is: 2022/3/6 09:30 
this Code: test代码
"""
import matplotlib.pyplot as plt
import numpy as np
from sklearn.metrics import confusion_matrix

if __name__ == '__main__':
    arr = np.load('/Users/yida/Desktop/code/Tools/Variable/0425/TrainSet1_224_112/0037/predict.npy')
    true = list(arr[0])
    for i in range(len(true)):
        if true[i] == 0:
            true[i] = 'ant'
        elif true[i] == 1:
            true[i] = 'bird'
        else:
            true[i] = 'cat'
    predict = list(arr[1])
    for i in range(len(predict)):
        if predict[i] == 0:
            predict[i] = 'ant'
        elif predict[i] == 1:
            predict[i] = 'bird'
        else:
            predict[i] = 'cat'

    print(true)
    matrix = confusion_matrix(true, predict)
    plt.matshow(matrix, cmap='Greys')
    plt.colorbar()
    plt.title("Confusion_Matrix")
    plt.savefig("1.jpg", dpi=300)
    plt.show()
    print("混淆矩阵:\n", matrix)
